/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.base.service.impl;

import java.util.Collection;
import java.util.List;

import com.xy.tool.context.UserContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xy.lang.domain.Result;
import com.xy.biz.base.domain.bo.CorpBO;
import com.xy.biz.base.domain.query.CorpQuery;
import com.xy.biz.base.service.CorpService;
import com.xy.biz.base.manager.CorpManager;

/**
 *
 *
 * @author zsp
 * @date 2020-9-3
 */
@Service
public class CorpServiceImpl implements CorpService {

	@Autowired
	private CorpManager corpManager;

	@Override
	public Result<?> saveCorp(CorpBO corpBO) {
		int affectedRows = corpManager.saveCorp(corpBO);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public Result<?> updateCorp(CorpBO corpBO) {
		int affectedRows = corpManager.updateCorp(corpBO);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public Result<?> deleteCorp(Long corpId) {
		int affectedRows = corpManager.deleteCorp(corpId);
		if (affectedRows > 0) {
			return Result.success();
		}
		return Result.ofErrorRowsAffected();
	}

	@Override
	public CorpBO getCorp(Long corpId) {
		return corpManager.getCorp(corpId);
	}

	@Override
	public List<CorpBO> listCorpById(Collection<Long> collection) {
		return corpManager.listCorpById(collection);
	}

	@Override
	public List<CorpBO> listCorp(CorpQuery query) {
//		query.setTenantId(UserContextHolder.getUserId());
		return corpManager.listCorp(query);
	}

	@Override
	public int countCorp(CorpQuery query) {
		return corpManager.countCorp(query);
	}

}
